import { msg } from '../../components/notice/notice';

Template.channel_members_list_item.helpers({
  display: function () {
    const user = Template.instance().data.result.user;
    if (user.profile.name) {
      return user.profile.name;
    } 
    return user.username;
  },

  username: function () {
    return Template.instance().data.result.user.username
  },

  avatar: function () {
    return Template.instance().data.result.user.profile.avatar;
  }
});

Template.channel_members_list_item.events({
  'click .remove-member' (e, instance) {
    e.preventDefault();
    Meteor.call('removeMember', { id: instance.data.result._id }, (err, res) => {
      if (res) {
        msg({content: '成功移除此用户'});
      }
    });
  }
});